﻿/// <reference path="../../Scripts/jquery-1.4.1.js" />

var _barcodeReady = [];

//条码水纹
$(document).ready(function () {
    var value = "刷条码处";
    $("#txtBarCode").val(value).focus(function () {
        if ($(this).val() == value) {
            $(this).val("");
        }
    }).blur(function () {
        if ($(this).val() == "") {
            $(this).val(value);
        }
    }).change(_dealBarcodeChanged); //.keydown(_dealBarcodeChanged);
});

function _dealBarcodeChanged() {
    var v = $(this).val();
    if (v.length == 13) {
        if (_barcodeReady.length > 0) {
            for (var i = 0; i < _barcodeReady.length; i++) {
                _barcodeReady[i](v);
            }
        }

        $(this).val("");
    }
}

function addBarcodeReadyHandler(func) {
    _barcodeReady[_barcodeReady.length] = func;
}

//标题
$(document).ready(function () {
    $("#contentTitle").html(document.title)
});

//Organize all urls used at client javascript coding.
//we can change it simply if we will deploy this website in a virtual dictionery in IIS.
function actionUrl(controller, action) {
    return mapUrl("~/" + controller + "/" + action + "/");
}

function mapUrl(netUrl) {
    return netUrl.replace("~/", "/BPM/");
}

function toggleMenuCategory(id) {
    var element = $("#" + id);
    if (element.is(":visible")) {
        element.slideUp(200);
    }
    else {
        element.slideDown(200);
    }
}